# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Xu Fasheng <fasheng.xu[AT]gmail.com>

pkgname=deepin-screenshot
pkgver=5.0.0
pkgrel=6
pkgdesc="Easy-to-use screenshot tool for linuxdeepin desktop environment"
arch=('loong64' 'x86_64')
url="https://github.com/linuxdeepin/deepin-screenshot"
license=('GPL3')
depends=('deepin-qt5integration' 'dtkwm' 'deepin-turbo')
makedepends=('cmake' 'ninja' 'qt5-tools')
source=("$pkgname-$pkgver.tar.gz::https://github.com/linuxdeepin/deepin-screenshot/archive/$pkgver.tar.gz"
        deepin-screenshot-no-notification.patch
        fix_copytoclipboard_in_kde_for_deepin-screenshot.patch)
sha512sums=('ad073961deaa78a47739af6cf8b0d0fa77a92ee6668c57f9a5bbf51ad2be1d2028681cffabdc26548be1bdbe24c7ccc7e7ff3d49b86907f794495bfbea62aa30'
            'be84065c3d81b60a3d04180f85b75a58f535a674f8438ee37ffa4f9a9c47128c48a5819d7279a977d64adfb9a25be51ec88f682b0ed632d1c676d6a8af174389'
            'f00ff0e15f0e7a76927594c4affe8fac557580ffe02b21669067d8ad03b121e30eb272e8984db8862047db914118b4ad21d6c20f438a51a884e0351426452c2a')

prepare() {
  cd deepin-screenshot-$pkgver
  patch -p1 -i ../deepin-screenshot-no-notification.patch

  # Rebased from https://gist.github.com/springzfx/f881dff2d1c89efbfe59cfc288e09462
  patch -p1 -i ../fix_copytoclipboard_in_kde_for_deepin-screenshot.patch

  sed -i '1i #include <QPainterPath>' src/widgets/shapeswidget.cpp
}

build() {
  cd deepin-screenshot-$pkgver
  cmake . -GNinja -DCMAKE_INSTALL_PREFIX=/usr
  ninja
}

package() {
  cd deepin-screenshot-$pkgver
  DESTDIR="$pkgdir" ninja install

  rm "$pkgdir"/usr/share/dbus-1/services/com.deepin.Screenshot.service
}
